#ifndef SCREENSHOT_H
#define SCREENSHOT_H

#include <QWidget>
#include "ScreenShotWidget_global.h"
#include "ScreenShotControlWidget.h"
#include "DrawLabel.h"
#include <QPoint>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QDialog>



///
/// \brief The ScreenShot class
/// 这是框选截屏区域类，后续还需要一个类实现在截图区域上绘制
class SCREENSHOTWIDGET_EXPORT ScreenShot : public QWidget
{
    Q_OBJECT
public:
    ///@brief 这个枚举类用于确认当前的截屏状态
    enum class CaptureStatus:std::uint8_t {
        Default=0,//默认状态
        Capturing,//鼠标按下后进入截图状态
        Captured,//鼠标释放后进入截屏结束状态
    };


public:

    explicit ScreenShot(QWidget *parent = nullptr);

    virtual void mouseMoveEvent(QMouseEvent *event)override;
    virtual void mousePressEvent(QMouseEvent *event)override;
    virtual void mouseReleaseEvent(QMouseEvent *event)override;
    virtual void paintEvent(QPaintEvent *event)override;
    virtual void keyPressEvent(QKeyEvent *event)override;

signals:
    ///@brief 确认保存截取的图片
    void VerifyScreenShotPicture();

    ///@brief 关闭截屏窗口
    void CloseScreenShotWidget();

public:
    ///@brief 获取第一次截取到的图片
    QPixmap GetGrabPixmap();

    ///@brief 获取添加标注之后的图片
    QPixmap GetFinalGrabPixmap()const;

    ///@brief  设置截图图片的存储路径
    void SetscreenShotPictureSavePath(const QString path);

    ///@brief 打开控制面板-工具栏
    void OpenControlToolBar();

    ///@brief 打开绘画面板
    void OpenDrawLabel();

    ///@brief 当前窗口和控制窗口的信号槽连接函数
    void ConnectSlotToControlWidget();

public:
    ///@brief 鼠标的按压起始位置和鼠标释放位置
    QPoint m_startPos,m_endPos;

    ///@brief 当前的状态
    CaptureStatus m_currentStatu=CaptureStatus::Default;

    ///@brief 存储截取到的图片
    QPixmap m_grapPicture;

    ///@brief 控制面板工具栏
    ScreenShotControlWidget *m_controlWidget;

    ///@brief 绘制画布
    DrawLabel *m_drawLabel;

    ///@brief 截屏照片的存储路径
    QString m_screenShotSavePath="";

};

#endif // SCREENSHOT_H
